home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <stdio.h>
- #include "MCDBcls.h"
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
-
- char *status[] = {
- " IDLE ",
- " WRITING ",
- " ERASING ",
- " BACKGROUND FORMAT ",
- " CLOSING TRACK ",
- " PREPARING ",
- " ABORTING ",
- " IMPORTING SESSION ",
- " BURN ERROR ABORTING "
- };
-
- char mediums[15][14] = {
- "mtUNKNOWN",
- "mtCDROM",
- "mtCDR",
- "mtCDRW",
- "mtDVDROM",
- "mtDVDR",
- "mtDVDRAM",
- "mtDVDRW",
- "mtDVDRWRO",
- "mtDVDRWSR",
- "mtDVDPLUSRW",
- "mtDVDPLUSR",
- "mtDDCDROM",
- "mtDDCDR",
- "mtDDCDRW"
- };
-
- CMCDBurner mcdb;
-
- void *MemoryFileHandle;
-
- void __stdcall OnWriteDone(BOOL FAILED, void *arg);
-
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
-
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- int i;
- for (i=0;i<mcdb.GetDeviceCount();i++)
- cbDrives->Items->Add(mcdb.GetDeviceName(i)); // add the ava
- if (cbDrives->Items->Count != 0)
- {
- cbDrives->ItemIndex = 0;
- mcdb.SelectDevice(0);
- }
- mcdb.UnlockDrive();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::cbDrivesChange(TObject *Sender)
- {
- mcdb.SelectDevice(cbDrives->ItemIndex);
- if (mcdb.DeviceIsBurner())
- bBurn->Enabled = TRUE;
- else
- bBurn->Enabled = FALSE;
- }
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::bEjectClick(TObject *Sender)
- {
- mcdb.EjectMedium();
- }
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::bBurnClick(TObject *Sender)
- {
- int i;
- String s;
- wchar_t sss[100];
- char sss2[256];
- HANDLE hFind;
- WIN32_FIND_DATA FindData;
- mcdb.ClearAll();
- // mcdb.SetBootImage("e:\\BootImage.img");
- mcdb.SetVolumeID("Label3");
- for (i=0;i<files->Items->Count;i++)
- {
- s = files->Items->Strings[i];
- mbstowcs(sss, s.c_str(), strlen(s.c_str())+1);
- if (DirectoryExists(s))
- {
- //mcdb.InsertDirW(L"\\", sss, L"*.*", True, cSavePath->Checked); // // for unicode
- mcdb.InsertDir("\\", s.c_str(), "*.*", True, cSavePath->Checked);
-
- }
- else if (FileExists(s))
- {
- //mcdb.InsertFileW(L"\\", sss); // for unicode
- mcdb.InsertFile("\\", s.c_str());
- // mcdb.InsertFileWithName("\\", s.c_str(), "New Long Name", "SHORTName");
- }
- }
- if (cImportSession->Checked)
- mcdb.ImportSession(0, "\\");
- mcdb.Prepare();
- /*
- if (mcdb.BuildISOImage("c:\\abcc.iso", &OnWriteDone, (void *)this)) // to Build .ISO uncomment this line
- Memo1->Lines->Add(">>> Building ISO Image ... ");
- else
- {
- strcpy(sss2, ">>> BuildISOImage() Start Failed. Error (");
- strcat(sss2, mcdb.GetErrorString());
- strcat(sss2, ")");
- Memo1->Lines->Add(sss2);
- }
- /*
- if (mcdb.BurnISOImage("c:\\abc.iso", &OnWriteDone, (void *)this)) // to Burn .ISO uncomment this line and comment mcdb.Prepare() (Above);
- ;
-
- */
-
- if (mcdb.Burn(&OnWriteDone, (void *)this) == TRUE)
- Memo1->Lines->Add(">>> WRITING DISC ... ");
- else
- {
- strcpy(sss2, ">>> Burn() Start Failed. Error (");
- strcat(sss2, mcdb.GetErrorString());
- strcat(sss2, ")");
- Memo1->Lines->Add(sss2);
- }
- }
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- double m, w;
- char buf[64];
- m = mcdb.GetImageSize();
- w = mcdb.GetBlocksWritten();
- pb->Max = m;
- pb->Position = w;
- if (mcdb.GetBlocksWritten() != 0)
- sprintf(buf, "%4.2f/%4.2f MB (%0.0f%%)", (double )((w * 2048) / 1024 / 1024), (double )((m * 2048)/ 1024 / 1024), w / m * 100);
- else
- sprintf(buf, "%4.2f/%4.2f MB", (double )((w * 2048) / 1024 / 1024), (double )((m * 2048)/ 1024 / 1024));
- lSize->Caption = buf;
- m = mcdb.GetCacheSize();
- w = mcdb.GetCachePosition();
- scs->Max = m;
- scs->Position = w;
- m = mcdb.GetDeviceBufferSize();
- w = mcdb.GetDeviceBufferPosition();
- dbs->Max = m;
- dbs->Position = w;
- Label2->Caption = status[mcdb.GetComponentState()];
- }
- //---------------------------------------------------------------------------
- void __stdcall TForm1::OnWriteDone(BOOL FAILED, void *arg)
- {
- TForm1 *Form1 = (TForm1 *) arg;
- if (FAILED)
- {
- char sss2[256];
- strcpy(sss2, ">>> WRITE DONE WITH ERROR (");
- strcat(sss2, mcdb.GetErrorString());
- strcat(sss2, ")");
- Form1->Memo1->Lines->Add(sss2);
- }
- else
- Form1->Memo1->Lines->Add(">>> WRITE DONE.");
- }
- //---------------------------------------------------------------------------
-
- void _stdcall TForm1::OnEraseDone(BOOL FAILED, void *arg)
- {
- TForm1 *Form1 = (TForm1 *) arg;
- if (FAILED)
- Form1->Memo1->Lines->Add(">>> ERASE DONE WITH ERROR");
- else
- Form1->Memo1->Lines->Add(">>> ERASEDISC DONE");
- }
-
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::bEraseClick(TObject *Sender)
- {
- mcdb.TestUnitReady();
- if (mcdb.TestUnitReady())
- {
- if (mcdb.Erasable())
- {
- Memo1->Lines->Add(">>> QUICK ERASING DISC ... ");
- mcdb.EraseDisc(TRUE, &OnEraseDone, (void *)this);
- }
- else
- Memo1->Lines->Add(">>> DISC IS NOT ERASABLE ... ");
- }
- else
- Memo1->Lines->Add(">>> DRIVE NOT READY ... ");
- }
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::bLoadClick(TObject *Sender)
- {
- mcdb.LoadMedium();
- }
- //---------------------------------------------------------------------------
-
-
- void __fastcall TForm1::filesDragOver(TObject *Sender, TObject *Source,
- int X, int Y, TDragState State, bool &Accept)
- {
- Accept = Source->ClassNameIs("TDirectoryListBox") || Source->ClassNameIs("TFileListBox");
- }
-
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::filesDragDrop(TObject *Sender, TObject *Source,
- int X, int Y)
- {
- int i;
- String tmp;
-
- if( Source->ClassNameIs("TDirectoryListBox"))
- {
- tmp = lbDir->GetItemPath(lbDir->ItemIndex);
- if ( tmp[tmp.Length()] == '\\' )
- {
- tmp = tmp.SubString(0,tmp.Length()-1);
- }
- files->Items->Add(tmp);
- }
- if ((Source->ClassNameIs("TFileListBox")) )
- {
- for (i=0;i < lbFiles->Items->Count; i++)
- {
- if (lbFiles->Selected[i])
- {
- tmp = lbDir->Directory;
- if ( tmp[tmp.Length()] == '\\' )
- {
- tmp = tmp.SubString(0,tmp.Length()-1);
- }
- tmp = tmp + '\\' + ExtractFileName(lbFiles->Items->Strings[i].c_str());
- files->Items->Add(tmp);
- }
- }
- }
-
- }
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::DeleteItem1Click(TObject *Sender)
- {
- if (files->ItemIndex != -1)
- files->Items->Delete(files->ItemIndex);
-
- }
-
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- char tmpstr[100] = ">>> DISC IN DRIVE IS ";
- strcat(tmpstr, mediums[mcdb.DiscIs()]);
- Memo1->Lines->Add(">>> TestUnitReady(): "+IntToStr((__int64) mcdb.TestUnitReady()));
- Memo1->Lines->Add(tmpstr);
- Memo1->Lines->Add(">>> Erasable(): "+IntToStr((__int64) mcdb.Erasable()));
- Memo1->Lines->Add(">>> Writable(): "+IntToStr((__int64) mcdb.Writable()));
- Memo1->Lines->Add(">>> SessionsOnDisc(): "+IntToStr((__int64) mcdb.SessionsOnDisc()));
- Memo1->Lines->Add(">>> GetTotalBlocksOnDisc(): "+IntToStr((__int64) (mcdb.GetTotalBlocksOnDisc() * 0.001953125) )+" MB");
- Memo1->Lines->Add(">>> GetFreeBlocksOnDisc(): "+IntToStr((__int64) (mcdb.GetFreeBlocksOnDisc() * 0.001953125) )+" MB");
- Memo1->Lines->Add(">>> DC_TEST_WRITE capable ? " + IntToStr(mcdb.DeviceCan(DC_TEST_WRITE)));
- Memo1->Lines->Add(">>> DC_UNDERRUNPROTECTION capable ? " + IntToStr(mcdb.DeviceCan(DC_UNDERRUNPROTECTION)));
- Memo1->Lines->Add(">>> READ_CDR capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_CDR)));
- Memo1->Lines->Add(">>> READ_CDRW capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_CDRW)));
- Memo1->Lines->Add(">>> READ_DVDRAM capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_DVDRAM)));
- Memo1->Lines->Add(">>> READ_DVDR capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_DVDR)));
- Memo1->Lines->Add(">>> READ_DVDRW capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_DVDRW)));
- Memo1->Lines->Add(">>> READ_DVDPLUSR capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_DVDPLUSR)));
- Memo1->Lines->Add(">>> READ_DVDPLUSRW capable ? " + IntToStr(mcdb.DeviceCan(DC_READ_DVDPLUSRW)));
- Memo1->Lines->Add(">>> WRITE_CDR capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_CDR)));
- Memo1->Lines->Add(">>> WRITE_CDRW capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_CDRW)));
- Memo1->Lines->Add(">>> WRITE_DVDRAM capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_DVDRAM)));
- Memo1->Lines->Add(">>> WRITE_DVDR capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_DVDR)));
- Memo1->Lines->Add(">>> WRITE_DVDRW capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_DVDRW)));
- Memo1->Lines->Add(">>> WRITE_DVDPLUSR capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_DVDPLUSR)));
- Memo1->Lines->Add(">>> WRITE_DVDPLUSRW capable ? " + IntToStr(mcdb.DeviceCan(DC_WRITE_DVDPLUSRW)));
- }
- //---------------------------------------------------------------------------
-
-
-
- void __fastcall TForm1::ClearAll1Click(TObject *Sender)
- {
- Memo1->Lines->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Panel4Click(TObject *Sender)
- {
- mcdb.AbortBurn();
- }
- //---------------------------------------------------------------------------
-
-
-